package cn.anosi.service.auth.impl;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import org.springframework.stereotype.Service;

import cn.anosi.entity.auth.RolePermission;
import cn.anosi.page.PageResponseBean;
import cn.anosi.page.Pager;
import cn.anosi.service.auth.RolePermissionService;
import cn.anosi.service.base.impl.BaseServiceImpl;

@Service
public class RolePermissionServiceImpl extends BaseServiceImpl<RolePermission> implements RolePermissionService{

	@Override
	public RolePermission save(RolePermission entity) {
		return null;
	}

	@Override
	public int delete(Serializable id) {
		return 0;
	}

	@Override
	public RolePermission getById(Serializable id) {
		return null;
	}

	public List<RolePermission> findAll() {
		return null;
	}

	@Override
	public List<Integer> getPermissionIds(Integer id) {
		return rolePermissionRepository.getPermissionIds(id);
	}

	@Override
	public int associatePermission(Integer roleId, List<Integer> ids) {
		int result = rolePermissionRepository.deletePermissionByRoleId(roleId);
		
		int times = 0;
		if(ids.size() >0){
			for (Integer id : ids) {
				times += rolePermissionRepository.associate(roleId ,id);
			}
			customRealm.clearCached();
			return times;
		}else{
			customRealm.clearCached();
			return result;
		}
	}

	@Override
	public List<RolePermission> list() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public PageResponseBean<RolePermission> list(Pager pager) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public int lock(Serializable id, Integer status) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public int batcahDel(List ids) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public int batchSave(ArrayList<RolePermission> list) {
		// TODO Auto-generated method stub
		return 0;
	}
}
